#! /bin/sh
#
# rcS           Call all S??* scripts in /etc/rcS.d in
#               numerical/alphabetical order.
#
# Version:      @(#)/etc/init.d/rcS  2.76  19-Apr-1999  miquels@cistron.nl
#
trap "" SIGHUP

PATH=/sbin:/bin:/usr/sbin:/usr/bin
runlevel=S
prevlevel=N
umask 022
export PATH runlevel prevlevel

#
#       Trap CTRL-C &c only in this shell so we can interrupt subprocesses.
#
trap ":" INT QUIT TSTP

mount -n /proc
#mount -n -o remount,rw /
#mount /var
mount -n -a

#
# Workaround for RESET_CAUSE issue
#
echo "setpermenv RESET_CAUSE 0" > /proc/ticfg/env

# unreserve for unp systems
echo "0 0" > /proc/sys/vm/pagetable_cache
# router
#echo 1 > /proc/sys/net/ipv4/ip_forward
# pppox
echo 1 > /proc/sys/net/ipv4/ip_dynaddr
# ignore_all not yet used: this should be satisfactory
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
# drop spoofed addr: turn this off on non-loop-free networks
# echo 1 > /proc/sys/net/ipv4/conf/default/rp_filter
# echo 1 > /proc/sys/net/ipv4/conf/all/rp_filter
# do not honor source route flags
echo 0 > /proc/sys/net/ipv4/conf/default/accept_source_route
echo 0 > /proc/sys/net/ipv4/conf/all/accept_source_route
# protect against syn flood attacks
echo 1 >/proc/sys/net/ipv4/tcp_syncookies
# this needs proper sampling on av_blog to determine optimal value
# for now just observe softnet_stats to see # time was throttled
# historical value was 300
echo 100 > /proc/sys/net/core/netdev_max_backlog
echo 10  > /proc/sys/net/core/no_cong
echo 30  > /proc/sys/net/core/lo_cong
echo 50  > /proc/sys/net/core/mod_cong

#####################################################################
# Cyril: Added to accomodate for difference between regular HDD type
# block devices and random-access compressed devices such as squashfs
# on flash.
echo 0 > /proc/sys/vm/page-cluster
echo 1 > /proc/sys/vm/max-readahead
echo 1 > /proc/sys/vm/min-readahead
#####################################################################

# Set default hostname to localhost
# This can be overridden later once we have DHCP
hostname localhost

# IGMP Proxy
#echo 220 > /proc/sys/net/ipv4/igmp_max_memberships

(cd /; tar xf var.tar)

#/sbin/ledcfg
#sleep 1

#/sbin/insmod avalanche_usb
#sleep 1

#/sbin/insmod tiatm
#sleep 1

# UPnP requires loopback
ifconfig lo 127.0.0.1

/usr/sbin/thttpd -d /usr/www -u root -p 80 -c '/cgi-bin/*' -l /dev/null

/usr/sbin/lightbox
sleep 1

/usr/bin/cm_pc > /dev/tts/0 &
/usr/sbin/sipxmppserver
